<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>递归实现深拷贝 - 思路</title>
</head>
<body>
    <script>    
        //目标数据
        const school = {
            name: '尚硅谷',
            pos: ['北京','上海','深圳','武汉','西安'],
            founder: {
                name:'刚哥',
                age: 45
            },
            //方法
            improve: function(){
                console.log('提升自己');
            }
        };

        //创建一个容器
        let container = {};
        //添加属性
        container.name = school.name;
        //拷贝 pos 属性
        container.pos = [];
        container.pos[0] = school.pos[0];
        container.pos[1] = school.pos[1];
        container.pos[2] = school.pos[2];
        container.pos[3] = school.pos[3];
        container.pos[4] = school.pos[4];

        //拷贝 founder
        container.founder = {};
        container.founder.name = '刚哥';
        container.founder.age = 45;

        //拷贝 improve
        container.improve = school.improve;

        console.log(container);

    </script>
</body>
</html>